home *** CD-ROM | disk | FTP | other *** search
- ' FRIENDS.BAS
- ' This program demonstrates the INPUT# statement.
-
- CLS
-
- OPEN "FRIENDS.TXT" FOR OUTPUT AS #1 ' open file for output
-
- PRINT "Enter the names of four of your friends"
- PRINT
-
- FOR i% = 1 TO 4 ' loop 4 times
- INPUT "Friendly name: ", pal$ ' each time get name from user
- WRITE #1, pal$ ' and write it to disk
- NEXT i%
-
- CLOSE #1 ' close the file
-
- OPEN "FRIENDS.TXT" FOR INPUT AS #1 ' reopen the file for input
-
- PRINT
- PRINT "You entered the following names:"
- PRINT
-
- FOR i% = 1 TO 4 ' loop 4 times
- INPUT #1, pal$ ' each time get name from file
- PRINT pal$ ' and display it on screen
- NEXT i%
-
- CLOSE #1 ' close the file
-
-